/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.d.ui.slice;

import com.d.ui.ResourceTable;
import com.d.ui.layout.arcmenu.ArcMenuAbilitySlice;
import com.d.ui.layout.banner.BannerAbilitySlice;
import com.d.ui.layout.heartlayout.HeartAbilitySlice;
import com.d.ui.layout.poi.PoiAbilitySlice;
import com.d.ui.layout.praise.PraiseAbilitySlice;
import com.d.ui.layout.shadow.ShadowAbilitySlice;
import com.d.ui.view.advertswitcher.AdvertSwitcherAbilitySlice;
import com.d.ui.view.clock.ClockSetAbilitySlice;
import com.d.ui.view.flowlayout.FlowLayoutAbilitySlice;
import com.d.ui.view.lrc.LrcViewAbility;
import com.d.ui.view.progress.ProgressActivity;
import com.d.ui.view.recordtrigger.RecordTriggerActivity;
import com.d.ui.view.replybg.ReplyBgViewAbility;
import com.d.ui.view.sort.SortActivity;
import com.d.ui.view.stroke.HoleBgActivitySlice;
import com.d.ui.view.tick.TickActivityAbilitySlice;
import com.d.ui.view.toggle.ToggleButtonAbilitySlice;
import com.d.ui.view.verinor.VerInorAbilitySlice;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;

public class MainAbilitySlice extends AbilitySlice {

  public void onClick(Component c) {
    AbilitySlice abilitySlice = null;
    switch (c.getId()) {
      case ResourceTable.Id_btn_lrc:
        abilitySlice = new LrcViewAbility();
        break;
      case ResourceTable.Id_btn_sort:
        abilitySlice = new SortActivity();
        break;
      case ResourceTable.Id_btn_tick:
        abilitySlice = new TickActivityAbilitySlice();
        break;
      case ResourceTable.Id_btn_stoke:
        abilitySlice = new HoleBgActivitySlice();
        break;
      case ResourceTable.Id_btn_toggle:
        abilitySlice = new ToggleButtonAbilitySlice();
        break;
      case ResourceTable.Id_btn_replybg:
        abilitySlice = new ReplyBgViewAbility();
        break;
      case ResourceTable.Id_btn_arcmenu:
        abilitySlice = new ArcMenuAbilitySlice();
        break;
      case ResourceTable.Id_btn_heart:
        abilitySlice = new HeartAbilitySlice();
        break;
      case ResourceTable.Id_btn_progress:
        abilitySlice = new ProgressActivity();
        break;
      case ResourceTable.Id_btn_shadow:
        abilitySlice = new ShadowAbilitySlice();
        break;
      case ResourceTable.Id_btn_recordtrigger:
        abilitySlice = new RecordTriggerActivity();
        break;
      case ResourceTable.Id_btn_verinor:
        abilitySlice = new VerInorAbilitySlice();
        break;
      case ResourceTable.Id_btn_clockset:
        abilitySlice = new ClockSetAbilitySlice();
        break;
      case ResourceTable.Id_btn_advert_switcher:
        abilitySlice = new AdvertSwitcherAbilitySlice();
        break;
      case ResourceTable.Id_btn_advert_flow_layout:
        abilitySlice = new FlowLayoutAbilitySlice();
        break;
      case ResourceTable.Id_btn_banner:
        abilitySlice = new BannerAbilitySlice();
        break;
      case ResourceTable.Id_btn_poi:
        abilitySlice = new PoiAbilitySlice();
        break;
      case ResourceTable.Id_btn_praise:
        abilitySlice = new PraiseAbilitySlice();
        break;
    }

    if (abilitySlice == null) {
      return;
    }

    present(abilitySlice, new Intent());
  }

  @Override
  public void onStart(Intent intent) {
    super.onStart(intent);
    getWindow().setStatusBarColor(0xFF008577);
    super.setUIContent(ResourceTable.Layout_ability_main);
    bindView();
  }

  private void bindView() {
    findComponentById(ResourceTable.Id_btn_lrc).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_sort).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_tick).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_toggle).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_replybg).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_stoke).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_arcmenu).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_heart).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_progress).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_shadow).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_recordtrigger).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_verinor).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_clockset).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_advert_switcher).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_advert_flow_layout).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_banner).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_poi).setClickedListener(this::onClick);
    findComponentById(ResourceTable.Id_btn_praise).setClickedListener(this::onClick);
  }

  @Override
  public void onActive() {
    super.onActive();
  }

  @Override
  public void onForeground(Intent intent) {
    super.onForeground(intent);
  }
}
